-- 
-- We include instructions for customizing the empty product.
--

-- Set the module name to the product's main module
--{-# OPTIONS -fglasgow-exts #-}
module HplProducts.EmptyTypes where

-- Add imports for product-specific modules
import FeatureModel.Types hiding (Success,Fail)
import Data.Generics
import BasicTypes

data SPLModel = SPLModel {
  -- Add product-specific model parts
}

data InstanceModel = InstanceModel {
  featureConfiguration :: FeatureConfiguration
  -- Add product-specific model parts
} deriving (Data, Typeable)


-- *******************************************************************************************************************************
-- we move the TransformationModel data type from Empty.hs module to EmptyTypes.hs module to execute the CK XML parser code
-- we bring the CK definition from Hephaestus code e remove it of Empty.hs module, too.
-- *******************************************************************************************************************************

 -- Add embedding constructors for product-specific transformations
data TransformationModel = UndefinedTransformation

--   The model used to relate feature expressions 
--   to transformations. The configuration knowledge 
--   guides the 'building' process of SPL instances.
type ConfigurationKnowledge = [ConfigurationItem]

data ConfigurationItem = 
 ConfigurationItem {
   expression :: FeatureExpression,                -- ^ if expression holds True for a product configuration...
   transformations :: [TransformationModel]        -- ^ the list of transformations would be applied.
 } | 
 ConstrainedConfigurationItem { 
   expression :: FeatureExpression,                -- ^ if expression holds True for a product configuration...
   transformations :: [TransformationModel],       -- ^ the list of transformations would be applied.
   required :: FeatureExpression,     -- ^ required expression for this configuration 
   provided :: FeatureExpression      -- ^ provided expression for this configuration
 }

constrained :: ConfigurationItem -> Bool 
constrained (ConstrainedConfigurationItem _ _ _ _) = True
constrained _ = False


-----------------------------------------------------------------------------------------
-- This function is used by CK ParserXML. It was brought from module CK.Parsers.XML.XmlConfigurationKnowledge of Hephaestus 
-----------------------------------------------------------------------------------------       
xml2Transformation :: String -> [String] -> ParserResult TransformationModel
xml2Transformation "Undefined" _ = undefined
--xml2Transformation "selectScenarios" x = Success (UseCaseTransformation (SelectScenarios x))
--xml2Transformation "selectUseCases" x = Success (UseCaseTransformation (SelectUseCases x))
--xml2Transformation "bindParameter" [x,y] = Success (UseCaseTransformation (BindParameter x y)) 
--xml2Transformation "evaluateAspects" x = Success (UseCaseTransformation (EvaluateAspects x))


   --"selectComponents" -> Success (GenT (SelectComponents as))

   --"selectAndMoveComponent" -> case as of
   --                             [x,y] -> Success (GenT (SelectAndMoveComponent x y))
   --                             otherwise -> Fail "Invalid number of arguments to the select and move transformation"

   --"createBuildEntries" -> Success (GenT (CreateBuildEntries as))
   
   --"preprocessFiles" -> Success (GenT (PreProcessor as))

  

